﻿using System.Linq;
using System.Web.Mvc;
using MRGSP.SurveyMaster.Core.Service;
using Omu.ValueInjecter;

namespace MRGSP.SurveyMaster.Infra.ValueInjections
{
    public class ByteToLookup : LoopValueInjection<byte, object>
    {
        protected override object SetValue(byte sourceValue)
        {
            return IoC.Resolve<IRoleService>().GetAll()
                .Select(o => new SelectListItem 
                                 {
                                     Text = o.Name, 
                                     Value = o.Id.ToString(), 
                                     Selected = o.Id == sourceValue
                                 });
        }
    }
}